const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    trainId: null,
    coachAssessment: '',
    finishQuality: null,
    trainStrength: null,
    memberFeeling: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    const trainId = wx.getStorageSync("trainId");
    this.setData({
      trainId
    });
  },
  bindTextArea:function(e){
    this.setData({
      coachAssessment: e.detail.value
    });
  },
  changeQuality: function(e) {
    const value = e.currentTarget.dataset.value;
    this.setData({
      finishQuality: value
    });
  },
  changeStrength: function(e) {
    const value = e.currentTarget.dataset.value;
    this.setData({
      trainStrength: value
    });
  },
  changeFeeling: function(e) {
    const value = e.currentTarget.dataset.value;
    this.setData({
      memberFeeling: value
    });
  },
  save: function() {
    const coachAssessment = this.data.coachAssessment;
    const finishQuality = this.data.finishQuality;
    const trainStrength = this.data.trainStrength;
    const memberFeeling = this.data.memberFeeling;
    const trainId = this.data.trainId;
    const url = app.globalData.url;
    wx.request({
      url: url + '/train/finishTrainByCoach',
      data: {
        trainId,
        coachAssessment,
        finishQuality,
        trainStrength,
        memberFeeling
      },
      method: 'POST',
      success: function(response) {
        if (response.data.success) {
          wx.navigateBack({
            delta:2
          });
        }else{
          wx.showToast({
            title: '保存失败:' + response.data.message,
            icon:'none'
          })
        }
      }
    })
  }
})